package com.bwie.service.impl;

import com.bwie.mapper.AdmissionsMapper;
import com.bwie.pojo.R;
import com.bwie.pojo.po.AdmissionsPo;
import com.bwie.service.AdmissionsService;
import com.google.common.hash.BloomFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdmissionsServiceImpl implements AdmissionsService {
    @Autowired
    private AdmissionsMapper admissionsMapper;
    @Autowired
    private BloomFilter<String> bloomFilter;
    @Override
    public R getList(Integer changeId) {
        List<AdmissionsPo> list = admissionsMapper.getList(changeId);
        return R.ok().data(list);
    }

    /**
     * 评价添加
     * @param admissionsPo
     * @return
     */
    @Override
    public R add(AdmissionsPo admissionsPo) {
        boolean equals = bloomFilter.equals(admissionsPo.getAppraiseMsg());
        if(equals == true){
            return R.err().msg("已存在");
        }
        admissionsMapper.add(admissionsPo);
        bloomFilter.put(admissionsPo.getAppraiseMsg());
        return R.ok();
    }


}
